﻿using System;
using System.Collections.Generic;
using System.Text;

namespace OG_UPDATETOOL
{
    public static class Crc16
    {
		public static int crc16(byte[] addr)
		{
			int j, temp;
			int crc = 0xFFFF;

			for(UInt16 i = 0;i<addr.Length;i++)
            {
				int tmp = addr[i];
				crc = crc ^ tmp;
				for (j = 0; j < 8; j++)
				{
					temp = crc & 0x0001;
					crc = crc >> 1;
					if (temp !=0)
					{
						crc = crc ^ 0xA1CD;
					}
				}
			}
			return crc;
		}
	}
}
